<!DOCTYPE html>
<html class="x-admin-sm">
    
 {include file="public/head"}

    <body>
        <div class="x-nav">
            <span class="layui-breadcrumb"> 
                <a href="">首页</a>
                <a href="">蔬菜商品管理</a>
                <a>蔬菜管理</a>
                <a><cite>蔬菜查询</cite></a>
            </span>
            <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
                <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
            </a>
        </div>
        <div class="layui-fluid">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-body ">
                            <form class="layui-form layui-col-space5" action="{:url('Admin/shucaichaxun')}" method="post">
                                <div class="layui-input-inline layui-show-xs-block">
                                    <input type="text" class="layui-input" placeholder="请输入蔬菜名" name="cate_name"></div>
                                <div class="layui-input-inline layui-show-xs-block">
                                    <button  type="submit" class="layui-btn"  lay-submit="" lay-filter="sreach" ><i class="layui-icon">&#xe615;</i> 查询</button>
                                </div>
                            </form>
                            <hr>
                        </div>
                        <div class="layui-card-body ">
                            <table class="layui-table layui-form" style="table-layout:fixed">
                              <thead>
                                <tr>
                                  <th width="5px">
                                    <input type="checkbox" name="" lay-skin="primary">
                                  </th>
                                  <th width="5px">序号</th>
                                  <th width="20px">图片</th>
                                  <th width="20px">蔬菜名</th>
                                  <th width="5px">排序</th>
                                  <th width="5px">库存</th>
                                  <th width="5px">单价</th>
                                  <th width="10px">蔬菜类型</th>
                                  <th width="10px">供应商</th>
                                  <th width="10px">是否上架</th>
                                  <th width="50px">操作</th>
                                </tr>
                              </thead>
                              <tbody class="x-cate">
                        
                               {volist name="shucaichaxun" id="vo" $i++=1}
                                <tr cate-id='1' fid='0' >
                                  <td>
                                    <input type="checkbox" name="" lay-skin="primary">
                                  </td>
                                  <td>{$i}</td>
                                  <td>{$vo.url}</td>
                                  <td>{$vo.vname}</td>
                                  <td>{$vo.paixu}</td>
                                  <td>{$vo.kucun}</td>
                                  <td>{$vo.price}</td>
                                  <td>{$vo.leixing}</td> 
                                  <td>{$vo.gname}</td>
                                  <td>
                                    <input type="checkbox" name="switch"  lay-text="是|否"  checked="" lay-skin="switch">
                                  </td>
                                  <td class="td-manage">
                                 <button class="layui-btn layui-btn layui-btn-xs"  onclick="xadmin.open('编辑','shucaiedit?id={$vo.vid}')" ><i class="layui-icon">&#xe642;</i>编辑</button>
                                    <a href="{:url('shucaidelete',['id'=>$vo['vid']])}">
                                    <button type="submit" class="layui-btn-danger layui-btn layui-btn-xs"  onclick="" href="javascript:;" ><i class="layui-icon">&#xe640;</i>删除</button>
                                    </a>

                                  </td>
                                </tr>
                               {/volist}
                              </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <script>
          layui.use(['form'], function(){
            form = layui.form;
            
          });

           /*用户-删除*/
          function member_del(obj,id){
              layer.confirm('确认要删除吗？',function(index){
                  //发异步删除数据
                  $(obj).parents("tr").remove();
                  layer.msg('已删除!',{icon:1,time:1000});
              });
          }

          // 分类展开收起的分类的逻辑
          // 
          $(function(){
            $("tbody.x-cate tr[fid!='0']").hide();
            // 栏目多级显示效果
            $('.x-show').click(function () {
                if($(this).attr('status')=='true'){
                    $(this).html('&#xe625;'); 
                    $(this).attr('status','false');
                    cateId = $(this).parents('tr').attr('cate-id');
                    $("tbody tr[fid="+cateId+"]").show();
               }else{
                    cateIds = [];
                    $(this).html('&#xe623;');
                    $(this).attr('status','true');
                    cateId = $(this).parents('tr').attr('cate-id');
                    getCateId(cateId);
                    for (var i in cateIds) {
                        $("tbody tr[cate-id="+cateIds[i]+"]").hide().find('.x-show').html('&#xe623;').attr('status','true');
                    }
               }
            })
          })

          var cateIds = [];
          function getCateId(cateId) {
              $("tbody tr[fid="+cateId+"]").each(function(index, el) {
                  id = $(el).attr('cate-id');
                  cateIds.push(id);
                  getCateId(id);
              });
          }
   
        </script>
    </body>
</html>
